//
// Created by haoy on 2017/9/11.
//

#include "h264_nal.hpp"

#include <map>
#include <string>

namespace h264 {
std::string nal_type_name(nal_type t) {
    std::map<nal_type, std::string> names = {
            {reserved_0, "0"},
            {slice_non_idr, "non idr"},
            {slice_data_partition_a, "sdp a"},
            {slice_data_partition_b, "sdp b"},
            {slice_data_partition_c, "sdp c"},
            {slice_idr, "idr"},
            {supplement_enhancement_information, "sei"},
            {SPS, "sps"},
            {PPS, "pps"},
            {access_unit_delimiter, "aud"},
            {end_of_sequence, "end of sequence"},
            {end_of_stream, "end of stream"},
            {filler_data, "filter data"},
            {sequence_parameter_set_extension, "sps ex"},
            {prefix_nal_unit, "prefix"},
            {subset_sequence_parameter_set, "ssps"},
            {depth_parameter_set, "dps"},
            {reserved_17, "17"},
            {reserved_18, "18"},
            {slice_layer_without_partitioning, "slice layer without partitioning"},
            {slice_layer_extension, "slice layer extension"},
            {slice_layer_extension_depth, "slice layer extension depth"},
            {reserved_22, "22"},
            {reserved_23, "23"},
            {STAP_A, "stap_a"},
            {single_time_aggregation_packet_b, "stap_b"},
            {multi_time_aggregation_packet_16, "mtap_16"},
            {multi_time_aggregation_packet_24, "mtap_24"},
            {fragment_unit_a, "fu_a"},
            {fragment_unit_b, "fu_b"},
            {reserved_30, "30"},
            {reserved_31, "31"}
    };
    auto name = names.find(t);
    if (name != names.end()) {
        return name->second;
    }
    return "unknown";
}
}